//
//  NBJEventAnnotation.m
//  nbj
//
//  Created by Francois Proulx on 09-10-03.
//  Copyright 2009 Toujours Saoul. All rights reserved.
//

#import "NBJEventAnnotation.h"

#import "NBJEvent.h"

@interface NBJEventAnnotation()

@property (nonatomic, readwrite, retain) NBJEvent *event;

@end

@implementation NBJEventAnnotation

@synthesize event;

- (id) initWithEvent:(NBJEvent *)anEvent
{
	self = [super init];
	if (self != nil) {
		self.event = anEvent;
	}
	return self;
}

- (void) dealloc
{
	self.event = nil;
	[super dealloc];
}

- (NSString *) externalMapUrlString
{
	return [NSString stringWithFormat:@"http://maps.google.com/maps?f=q&ll=%f,%f&z=19", self.coordinate.latitude, self.coordinate.longitude];
}

- (NSString *) externalRouteUrlStringStartingFrom:(CLLocationCoordinate2D)startCoords
{
	return [NSString stringWithFormat:@"http://maps.google.com/maps?f=d&dirflg=w&source=s_d&saddr=%f,%f&daddr=%f,%f", startCoords.latitude, startCoords.longitude, self.coordinate.latitude, self.coordinate.longitude];
}

#pragma mark -
#pragma mark MKAnnotation protocol

- (CLLocationCoordinate2D) coordinate
{
	CLLocationCoordinate2D coords;
	coords.latitude = [event.latitude doubleValue];
	coords.longitude = [event.longitude doubleValue];
	return coords;
}

- (NSString *)title
{
	return [event eventDescription];
}

- (NSString *)subtitle
{
	return event.address;
}

@end
